package com.jiangxfei.mymvp.di.module;


import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import com.jiangxfei.mymvp.base.BaseApplication;

import javax.inject.Named;
import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

@Module
public class AppModule {
    private Context mContext;

    public AppModule(BaseApplication myApplicationContext) {
        this.mContext = myApplicationContext;
    }

    @Singleton
    @Provides
    public Context getApplication() {
        return mContext;
    }

    @Singleton
    @Provides
    @Named("default")
    public SharedPreferences providerDefaultSharePreferences() {
        return PreferenceManager.getDefaultSharedPreferences(mContext);
    }

    @Singleton
    @Provides
    @Named("encode")
    public SharedPreferences providerEncodeSharePreferences() {
        return mContext.getSharedPreferences("encode", Context.MODE_PRIVATE);
    }

}
